package com.wy.powerbuilder.service.impl.ljh;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wy.powerbuilder.entity.ljh.Device;
import com.wy.powerbuilder.entity.ljh.Type;
import com.wy.powerbuilder.entity.lwg.houses;
import com.wy.powerbuilder.mapper.ljh.DeviceMapper;
import com.wy.powerbuilder.service.ljh.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeviceServiceImpl implements DeviceService {
    @Autowired
    private DeviceMapper deviceMapper;
    @Override
    public PageInfo<Device> selByPage(Integer pageNum, Integer pageSize,String model) {
        if (pageNum==null){
            pageNum=1;
        }
        /*

        对查询的信息进行分页
        第一个参数当前页码,第二个每页的条数
        */
        PageHelper.startPage(pageNum,pageSize) ; //使用分页插件开始分页
        //查询我们将要分页的信息
        List<Device> devices = deviceMapper.selAll(model);

        //将查询的维修信息放到分页对象中去
        PageInfo<Device> pageInfo = new PageInfo<>(devices);
        return pageInfo;
    }

    @Override
    public List<houses> seleAll() {
        return deviceMapper.seleAll();
    }

    @Override
    public int addDevice(Device device) {
        return deviceMapper.addDevice(device);
    }

    @Override
    public List<Type> all() {
        return deviceMapper.all();
    }

    @Override
    public int delDevice(Integer deviceid) {
        return deviceMapper.delDevice(deviceid);
    }

    @Override
    public Device seldeviceId(Integer deviceid) {
        return deviceMapper.seldeviceId(deviceid);
    }

    @Override
    public int updDevice(Device device) {
        return deviceMapper.updDevice(device);
    }


}
